local PANEL = {}

function PANEL:Init()
	self:SetTitle("Flood - Main Menu")

	self.Tabs = vgui.Create("DPropertySheet", self)
	
	self.Tabs:AddSheet("Help", self:CreateHelp(), "gui/silkicons/page", false, false, "Hey newbie, you lost? :(")
	self.Tabs:AddSheet("Team", vgui.Create("DPanel"), "gui/silkicons/group", false, false, "You and yarrr buddys!")
	self.Tabs:AddSheet("Shop", vgui.Create("DPanel"), "gui/silkicons/application_view_tile", false, false, "Spend your well heard cash!")
	self.Tabs:AddSheet("Settings", vgui.Create("DPanel"), "gui/silkicons/wrench", false, false, "*tweak tweak*")
	self.Tabs:AddSheet("About", vgui.Create("DPanel"), "gui/silkicons/plugin", false, false, "Who made this great gamemode?")
	
	self.btnClose:Remove()
	self.btnClose = vgui.Create("DImageButton", self)
	self.btnClose.DoClick = function() self:Close() end
	self.btnClose:SetMaterial("flood/gui_close")

	self:MakePopup()
end

function PANEL:Paint()
	draw.RoundedBox(8, 0, 0, self:GetWide(), self:GetTall(), Color(80, 80, 80, 255))
end

function PANEL:PerformLayout()
	self:SetSize(600, 400)
	self:SetPos(ScrW()/2 - self:GetWide()/2, ScrH()/2 - self:GetTall()/2) -- Center() invalidates layout <_<
    
    self.btnClose:SetPos( self:GetWide() - 40, 4 )
    self.btnClose:SetSize( 32, 32 )
    
    self.lblTitle:SetPos( 16, 8 )
    self.lblTitle:SetSize( self:GetWide() - 25, 20 )
    self.lblTitle:SetFont("Flood30")
	
	self.Tabs:SetPos(5, 40)
	self.Tabs:SetSize(self:GetWide()-10, self:GetTall()-45)
end

function PANEL:CreateHelp()
	local panel = vgui.Create("DPanel")
	panel.Paint = function()
		draw.RoundedBox(4, 0, 0, panel:GetWide(), panel:GetTall(), Color(40, 40, 40, 255))
	end

	local help = vgui.Create("HTML", panel)
	help:OpenURL("http://dev-zilla.net/floodhelp.html?name="..LocalPlayer():Nick().."&cash=1000")
	
	panel.PerformLayout = function()
		help:StretchToParent(8, 8, 8, 8)
	end
	
	return panel
end

vgui.Register("HelpMenu", PANEL, "DFrame")